package com.fr.data.core.define;

import com.fr.base.XMLable;
import com.fr.base.core.ComparatorUtils;
import com.fr.base.xml.XMLPrintWriter;
import com.fr.base.xml.XMLableReader;
import com.fr.data.core.DataXMLUtils;
import com.fr.data.util.function.DataFunction;

public class ChartSummaryColumn
  implements XMLable
{
  private String name;
  private String customName;
  private DataFunction function;

  public ChartSummaryColumn()
  {
    this.name = null;
    this.function = null;
  }

  public ChartSummaryColumn(String paramString)
  {
    this(paramString, null);
  }

  public ChartSummaryColumn(String paramString, DataFunction paramDataFunction)
  {
    this.name = null;
    this.function = null;
    setName(paramString);
    setFunction(paramDataFunction);
  }

  public ChartSummaryColumn(String paramString1, String paramString2, DataFunction paramDataFunction)
  {
    this.name = null;
    this.function = null;
    setName(paramString1);
    setCustomName(paramString2);
    setFunction(paramDataFunction);
  }

  public String getName()
  {
    return this.name;
  }

  public void setName(String paramString)
  {
    this.name = paramString;
  }

  public void setCustomName(String paramString)
  {
    this.customName = paramString;
  }

  public String getCustomName()
  {
    return this.customName;
  }

  public DataFunction getFunction()
  {
    return this.function;
  }

  public void setFunction(DataFunction paramDataFunction)
  {
    this.function = paramDataFunction;
  }

  public boolean equals(Object paramObject)
  {
    if (!(paramObject instanceof ChartSummaryColumn))
      return false;
    ChartSummaryColumn localChartSummaryColumn = (ChartSummaryColumn)paramObject;
    return ((ComparatorUtils.equals(localChartSummaryColumn.getName(), getName())) && (ComparatorUtils.equals(localChartSummaryColumn.getFunction(), getFunction())));
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    ChartSummaryColumn localChartSummaryColumn = (ChartSummaryColumn)super.clone();
    if (getFunction() != null)
      localChartSummaryColumn.setFunction((DataFunction)getFunction().clone());
    return localChartSummaryColumn;
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
    if (paramXMLableReader.isAttr())
    {
      String str;
      if ((str = paramXMLableReader.getAttr("name")) != null)
        this.name = str;
      if ((str = paramXMLableReader.getAttr("function")) != null)
        try
        {
          setFunction(DataXMLUtils.readXMLDataFunction(str));
        }
        catch (Exception localException)
        {
          throw new RuntimeException(localException.getMessage(), localException);
        }
      if ((str = paramXMLableReader.getAttr("customName")) != null)
        setCustomName(str);
    }
  }

  public void writeXML(XMLPrintWriter paramXMLPrintWriter)
  {
    paramXMLPrintWriter.startTAG("ChartSummaryColumn").attr("name", getName());
    if (getFunction() != null)
      paramXMLPrintWriter.attr("function", getFunction().getClass().getName());
    paramXMLPrintWriter.attr("customName", getCustomName());
    paramXMLPrintWriter.end();
  }
}